package com.ma.gulimall.ware.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ma.gulimall.to.mq.OrderTo;
import com.ma.gulimall.to.mq.StockLockedTo;
import com.ma.gulimall.utils.PageUtils;
import com.ma.gulimall.ware.entity.WareSkuEntity;
import com.ma.gulimall.ware.vo.SkuHasStockVo;
import com.ma.gulimall.ware.vo.WareSkuLockVo;

import java.util.List;
import java.util.Map;

/**
 * 商品库存
 *
 * @author mayongqiang
 * @email 178780494@qq.com
 * @date 2021-06-14 01:28:44
 */
public interface WareSkuService extends IService<WareSkuEntity> {

    /**
     * 02、查询商品库存
     * 请求参数
     * {wareId: 123,//仓库id
     * skuId: 123//商品id}
     */
    PageUtils queryPage(Map<String, Object> params);

    /**
     * 添加库存
     */
    void addStock(Long skuId, Long wareId, Integer skuNum);

    /**
     * 判断是否有库存
     */
    List<SkuHasStockVo> getSkusHasStock(List<Long> skuIds);

    /**
     * 下单 锁定库存
     */
    Boolean orderLockStock(WareSkuLockVo vo);

    /**
     * 解锁库存
     */
    void unlockStock(StockLockedTo to);

    void unlockStock(OrderTo orderTo);
}

